package com.ysd.lis.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ysd.common.Result;
import com.ysd.lis.entity.SysInterfaceExtValue;
import com.ysd.lis.mapper.SysInterfaceExtValueMapper;
import com.ysd.lis.service.SysInterfaceExtValueService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 预置场景-外源字段对照关系 服务实现类
 * </p>
 *
 * @author LiuQi
 * @since 2024-06-07
 */
@Service
public class SysInterfaceExtValueServiceImpl extends ServiceImpl<SysInterfaceExtValueMapper, SysInterfaceExtValue> implements SysInterfaceExtValueService {

    @Autowired
    SysInterfaceExtValueMapper sysInterfaceExtValueMapper;

    @Override
    public Result getExtValueList() {
        LambdaQueryWrapper<SysInterfaceExtValue> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(SysInterfaceExtValue::getDelFlag, 0);
        List<SysInterfaceExtValue> sysInterfaceExtValues = sysInterfaceExtValueMapper.selectList(lambdaQueryWrapper);
        return Result.succ(1, "查询成功！", sysInterfaceExtValues);
    }
    @Override
    public Result addExtValue(SysInterfaceExtValue sysInterfaceExtValue) {
        boolean save = this.save(sysInterfaceExtValue);
        if (save) {
            return Result.succ(1, "添加成功！", save);
        } else {
            return Result.fail("添加失败！");
        }
    }
    @Override
    public Result updateExtValue(SysInterfaceExtValue sysInterfaceExtValue) {
        boolean save = this.updateById(sysInterfaceExtValue);
        if (save) {
            return Result.succ(1, "编辑成功！", save);
        } else {
            return Result.fail("编辑失败！");
        }
    }
    @Override
    public Result deleteExtValue(SysInterfaceExtValue sysInterfaceExtValue) {
        boolean save = this.removeById(sysInterfaceExtValue.getId());
        if (save) {
            return Result.succ(1, "删除成功！", save);
        } else {
            return Result.fail("删除失败！");
        }
    }
}
